package cn.iocoder.yudao.module.erp.dal.mysql.customeraccount;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.erp.dal.dataobject.customeraccount.CustomerAccountDO;
import cn.iocoder.yudao.module.erp.dal.dataobject.customeraccount.CustomerAccountDetailDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.erp.controller.admin.customeraccount.vo.*;
import org.apache.ibatis.annotations.Param;

/**
 * 客户余额 Mapper
 *
 * @author mhc
 */
@Mapper
public interface CustomerAccountMapper extends BaseMapperX<CustomerAccountDO> {

    List<CustomerAccountDetailDO> findListByMap(@Param("query")Map<String,Object> query);

    default PageResult<CustomerAccountDO> selectPage(CustomerAccountPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<CustomerAccountDO>()
                .eqIfPresent(CustomerAccountDO::getCustomerId, reqVO.getCustomerId())
                .eqIfPresent(CustomerAccountDO::getNowCount, reqVO.getNowCount())
                .eqIfPresent(CustomerAccountDO::getSaleCount, reqVO.getSaleCount())
                .eqIfPresent(CustomerAccountDO::getBuyCount, reqVO.getBuyCount())
                .eqIfPresent(CustomerAccountDO::getRemark, reqVO.getRemark())
                .orderByDesc(CustomerAccountDO::getNowCount));
    }

}